home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / msdos / editors / eedraw / src / ed / program.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-15  |  7.3 KB  |  239 lines

  1. /*****************************************************************************
  2. * Definitions for the EEDRAW program:                         *
  3. *****************************************************************************/
  4.  
  5. #ifndef PROGRAM_H
  6. #define PROGRAM_H
  7.  
  8. #define LayerPointer EEActiveWindow->Layer
  9.  
  10. #define EEDRAW_VERSION    "Version 2.4"
  11.  
  12. #define PROGRAM_NAME    "EEdraw"
  13.  
  14. #include "intr_lib.h"
  15. #include "intr_gr.h"
  16.  
  17. typedef int        BooleanType;
  18. typedef unsigned char    ByteType;
  19.  
  20. #if !defined(FLOAT) && !defined(DOUBLE)
  21. #define DOUBLE
  22. typedef    double        RealType;
  23. #endif /* !FLOAT && !DOUBLE */
  24.  
  25. #ifdef VoidPtr
  26. #undef VoidPtr
  27. #endif /* VoidPtr */
  28.  
  29. #ifdef NO_VOID_PTR
  30. #define VoidPtr        char *
  31. #else
  32. #define VoidPtr        void *
  33. #endif /* NO_VOID_PTR */
  34.  
  35. #ifndef    NULL
  36. #define    NULL    0
  37. #endif
  38.  
  39. #ifndef    TRUE
  40. #define    TRUE    1
  41. #define    FALSE    0
  42. #endif
  43.  
  44. #ifndef LINE_LEN
  45. #define LINE_LEN_LONG    1024
  46. #define LINE_LEN    255
  47. #define LINE_LEN_SHORT    81
  48. #define FULL_PATH_LEN    81
  49. #define FILE_NAME_LEN    14
  50. #define MAX_PIN_INFO    10
  51. #endif
  52.  
  53. #define EE_ERASE_COLOR  (IntrAllocColor(EEActvWndwBackColor, INTR_INTENSITY_HIGH))
  54. #define EE_DRAW_COLOR  (IntrAllocColor(EEActvWndwForeColor, INTR_INTENSITY_VHIGH))
  55. #define EE_HIGHLIGHT_COLOR  (IntrAllocColor(EEHighLightColor, INTR_INTENSITY_VHIGH))
  56.  
  57. #define SIGN(x)        ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0))
  58. #define ABS(y)        ((y) > 0 ? (y) : (-(y)))
  59. #define SQR(y)        ((y) * (y))
  60. #define SGN(x)        ((x) > 0 ? 1 : ((x) == 0 ? 0 : -1))
  61. #define MIN(x, y)    ((x) > (y) ? (y) : (x))
  62. #define MAX(x, y)    ((x) > (y) ? (x) : (y))
  63. #define BOUND(x, Min, Max) (MIN(MAX((x), (Min)), (Max)))
  64. #define GEN_COPY(Dest, Src, Size)       memcpy(Dest, Src, Size)
  65.  
  66. #define INFINITY    1e6
  67. #define EPSILON        1e-6
  68.  
  69. #define DEG2RAD(Deg)    ((Deg) * M_PI / 180.0)
  70. #define RAD2DEG(Rad)    ((Rad) * 180.0 / M_PI)
  71.  
  72. #define BSPACE    8
  73. #define TAB    9
  74. #define LF    10
  75. #define CR    13
  76. #define ESC    27
  77.  
  78. #define PAGE_A4_XSIZE    1000         /* Regular page size (8" Epson printer) */
  79. #define PAGE_A4_YSIZE    640
  80.  
  81. /* Note the snap distance is also the scaler for libraries loaded in. */
  82. #define DEFAULT_SNAP_DISTANCE    16        /* Distance to snap a point. */
  83.  
  84. #define DEFAULT_ZOOM_FACTOR    -2             /* Zoom out by factor of 4. */
  85. #define DEFAULT_ZOOM(v)        ((v) >> 2)
  86. #define DEFAULT_INV_ZOOM(v)    ((v) << 2)
  87.  
  88. /* Macros to control coordinate to gird snapping in drawing space. */
  89. #define EE_SNAP(x)        (((x + EESnapDistance / 2) / EESnapDistance) \
  90.                                * EESnapDistance)
  91.  
  92. #define BOUNDARY_WIDTH        30
  93.  
  94. typedef enum {
  95.     DRAW_POLYLINE_STRUCT_TYPE,
  96.     DRAW_CONNECTION_STRUCT_TYPE,
  97.     DRAW_TEXT_STRUCT_TYPE,
  98.     DRAW_LIB_ITEM_STRUCT_TYPE,
  99.     DRAW_PICK_ITEM_STRUCT_TYPE
  100. } DrawStructureType;
  101.  
  102. typedef enum {
  103.     TEXT_ORIENT_NON = -1,
  104.     TEXT_ORIENT_HORIZ = GR_HORIZ_DIR,
  105.     TEXT_ORIENT_VERT = GR_VERT_DIR
  106. } TextOrientationType;
  107.  
  108. typedef struct DrawGenericStruct {
  109.     DrawStructureType StructType;
  110.     struct DrawGenericStruct *Pnext;
  111. } DrawGenericStruct;
  112.  
  113. typedef struct DrawPolylineStruct {
  114.     DrawStructureType StructType;
  115.     struct DrawGenericStruct *Pnext;
  116.     char Layer;
  117.     char name[0x8];        /* If Wire conection, Name, else attrib */
  118.     int NX,NY,Mode;        /* Name X,Y + Mode data for conection */
  119.     int Flags;
  120.     int Width;
  121.     int NumOfPoints;              /* Number of XY pairs in Points array. */
  122.     int *Points;            /* XY pairs that forms the polyline. */
  123. } DrawPolylineStruct;
  124.  
  125. typedef struct DrawConnectionStruct {
  126.     DrawStructureType StructType;
  127.     struct DrawGenericStruct *Pnext;
  128.     char Layer;
  129.     int PosX, PosY;                /* XY coordinates of connection. */
  130. } DrawConnectionStruct;
  131.  
  132. typedef struct DrawTextStruct {
  133.     DrawStructureType StructType;
  134.     struct DrawGenericStruct *Pnext;
  135.     char Layer;
  136.     int PosX, PosY, Scale;            /* XY coordinates of connection. */
  137.     TextOrientationType Orient;
  138.     char *Text;
  139. } DrawTextStruct;
  140.  
  141. typedef struct DrawLibItemStruct {
  142.     DrawStructureType StructType;
  143.     struct DrawGenericStruct *Pnext;
  144.     TextOrientationType PartNameOrient, ChipNameOrient;
  145.     char *PartName;      /* Name of part, i.e. "Op. Amp. 21". Not Chip Name. */
  146.     char *ChipName;       /* Key to look for in the library, i.e. "74LS00". */
  147.     int PartNameX, PartNameY;            /* Where PartName should be put. */
  148.     int ChipNameX, ChipNameY;            /* Where ChipName should be put. */
  149.     int Multi;             /* In multi unit chip - which unit to draw. */
  150.     int Transform[2][2];       /* The rotation/mirror transformation matrix. */
  151.     int PosX, PosY;                  /* Exact position of part. */
  152.     int BBoxMinX, BBoxMaxX, BBoxMinY, BBoxMaxY;     /* BBox around the part. */
  153. } DrawLibItemStruct;
  154.  
  155. typedef struct DrawPickedStruct { /* Holds structures picked by pick events. */
  156.     DrawStructureType StructType;
  157.     struct DrawPickedStruct *Pnext;
  158.     DrawGenericStruct *PickedStruct;
  159. } DrawPickedStruct;
  160.  
  161. typedef struct EEWindowStruct {
  162.     int IntrLibWindowID;
  163.     int PageXSize, PageYSize;
  164.     BooleanType Modified;
  165.     BooleanType IsFullSize;
  166.     char FileName[FULL_PATH_LEN + FILE_NAME_LEN];
  167.     char StatusL[0x18],StatusR[0x18];
  168.     IntrBBoxStruct BBox;
  169.     DrawGenericStruct *EEDrawList;       /* All objects of this file/window. */
  170.     struct LayerStruct *Layer;
  171.     struct EEWindowStruct *Pnext;
  172. } EEWindowStruct;
  173.  
  174.  
  175. typedef struct LayerStruct {
  176.     char LayerNames[45][8];
  177.     int  LayerColor[45];
  178.     char LayerStatus[45];
  179.     int  NumberOfLayers;
  180.     int CurrentLayer;
  181.     int CurrentWidth;
  182.     int CommonColor;
  183.     int Flags;
  184. }LayerStruct;
  185.  
  186. typedef struct NetListStruct {
  187.     char Pin[LINE_LEN_SHORT];
  188.     struct NetListStruct *Pnext;
  189. } NetListStruct;
  190.  
  191. extern int EEPageSizeX, EEPageSizeY; /* Clipping boundaries of current page. */
  192. extern int EESnapDistance;       /* Distance to snap a point to current one. */
  193. extern int EETextScale;          /* Scaling factor for text string drawing. */
  194. extern int EEWindowsFrameWidth;               /* Width of all drawings. */
  195. extern int EEListNumDisplayed;
  196. extern int EERootWindowID;        /* Intr_lib ID of the back ground color. */
  197. extern int EERootWndwFrameColor;
  198. extern int EERootWndwForeColor;
  199. extern int EERootWndwBackColor;
  200. extern int EERootWndwXorColor;
  201. extern int EEPopUpFrameColor;         /* Color for the pop up menus/queries. */
  202. extern int EEPopUpBackColor;
  203. extern int EEPopUpForeColor;
  204. extern int EEPopUpXorColor;
  205. extern int EEActvWndwFrameColor;
  206. extern int EEActvWndwForeColor;
  207. extern int EEActvWndwBackColor;
  208. extern int EEPsvWndwFrameColor;
  209. extern int EEPsvWndwForeColor;
  210. extern int EEPsvWndwBackColor;
  211. extern int EEHighLightColor;
  212. extern int EELayerWire;
  213. extern int EELayerBus;
  214. extern int EELayerGate;
  215. extern int EELayerIEEE;
  216. extern int EELayerPinFun;
  217. extern int EELayerPinNam;
  218. extern int EELayerPinNum;
  219. extern int EELayerRefDes;
  220. extern int EELayerAttr;
  221. extern int EELayerDevice;
  222. extern int EELayerNotes;
  223. extern int EELayerNetNam;
  224. extern int EELayerPin;
  225. extern BooleanType EESubName; /* Control the sub naming of devices */
  226. extern BooleanType EEAutoPan; /* Control auto panning in creation/placement. */
  227. extern BooleanType EEHVLineDrawing;  /* Draw only horizontal/vertical lines. */
  228. extern EEWindowStruct *EEActiveWindow, *EEWindowsList;
  229. extern IntrBBoxStruct *EEActiveBBox;
  230. /* extern LayerStruct *LayerPointer;    /* pointer in eelayer.h */
  231.  
  232. void PutCursorInActiveWindow(void);
  233. VoidPtr MyMalloc(unsigned size);
  234. void MyFree(VoidPtr);
  235. void MyExit(int ExitCode);
  236. void FatalError(char *ErrMsg);
  237.  
  238. #endif PROGRAM_H
  239.